package thread;

public class ThreadB extends Thread {
	public boolean flag = true;
	int total;
	
	public ThreadB(boolean flag){
		this.flag = flag;
	}
	
	@Override
	public void run() {
		synchronized (this) {
			while(flag){
				try {
					this.wait();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			System.out.println("ThreadB正在计算。。。");
			for(int i=1;i<101;i++){
				total += i;
			}
			flag = true;
			this.notify();
		}
	}
}
